import { uniqueKey } from "@/utils/judge"
import { getUnitDictList } from "@/api/common"
import {mesTmMaterialOrderOutStockPage} from "@/api/materials/tmMaterialOrder";

export const goodsDialog = {
  data() {
    return {
      goodsDialogVisible: false, //表格弹框隐藏显示
      mesTmMaterialOrderOutStockPage, // 获取弹框数据接口
      goodsHasFooter: true, // 是否需要底部按钮默认true
      operateList1: [
        {
          name: $i18n.t("common.cancel"),
          handleName: "cls" //点击时返回的标识
        },
        {
          name: $i18n.t("common.submit"),
          type: "primary",
          isMultiple: true, //至少选择一条
          //是否可点击；
          disabled: (data) => {
            console.log(data)
            return data.length < 1
          },
          handleName: "add" //点击时返回的标识
        }
      ],
      goodsSearchDialog: {
        inline: true,
        span: 24,
        formDesc: {
          tmOrderCode: {
            type: "input",
            layout: 8,
            label: "单号/编码"
          },
          materialName: {
            type: "input",
            layout: 8,
            label: "物料名称/编号"
          },
          materialBrand: {
            type: "input",
            layout: 8,
            label: "品牌"
          },
          materialUnit: {
            type: "input",
            layout: 8,
            label: "规格"
          },
        }
      },
      goodsDialogColumn: [
        {
          type: "selection",
          fixed: "left"
        },
        {
          type: "index",
          label: $i18n.t("common.order"),
          width: 60,
          fixed: "left"
        },
        {
          prop: "vinCode",
          label: "VIN",
          width: 150,
          showOverflowTooltip: true
        },
        {
          prop: "uwbCode",
          label: "UWB",
          width: 150,
          showOverflowTooltip: true
        },
        {
          prop: "tmOrderCode",
          label: "订单号",
          width: 150,
          showOverflowTooltip: true
        },
        {
          prop: "orderCode",
          label: "工单号",
          width: 150,
          showOverflowTooltip: true
        },
        {
          prop: "materialName",
          label:"物料名称",
          width: 150,
        },
        {
          prop: "materialCode",
          label: "物料编码",
          width: 130,
        },
        {
          prop: "materialNum",
          label: "物料数量",
          width: 130,
        },
        {
          prop: "materialBrand",
          label: "物料品牌",
          width: 130,
        },
        {
          prop: "materialUnit",
          label: "物料规格",
          width: 130,
        },
      ]
    }
  },
  methods: {
    // 弹框表格，双击表格，或者点击确定 返回选中数据
    handleOperateEvent1(data) {
      const fnc = {
        //   取消
        cls: () => {
          this.goodsDialogVisible = false
        },
        // 确认
        add: () => {
          if (data.rows.length != 0) {
            console.log("子组件data", data)
            this.setSelectGoods(data.rows)
            // this.$emit("getSelectData", data.rows);
            this.goodsDialogVisible = false
          } else {
            this.$message.warning("至少需要选择一条数据")
          }
        }
      }
      fnc[data.handleName]()
    }
  }
}
